home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir31
/
in_out.zip
/
FONETONE.ASM
next >
Wrap
Assembly Source File
|
1993-01-16
|
5KB
|
114 lines
;=============================================================================
;Example:
; TASM FONETONE.ASM
; TLINK/T FONETONE.OBJ
;
;If you are using the A86 assembler -
;place a "x" between bit 0 and the letter "B"
;in each of the binary numbers below.
;
;Example: 00000011xB
;
;==============================================================================
;
code_seg SEGMENT
ASSUME cs:code_seg, ds:code_seg, es:code_seg, ss:code_seg
ORG 100h
begin:
jmp start
;----------------------------------
;William Cravener ;Author
;520 North Stateline Rd
;Sharon, Pa 16146
;----------------------------------
delay DW 0
message1 DB 'Press Esc to Quit', 0dh, 0ah, '$'
message2 DB 'Press any other key to play$'
;----------------------------------
start PROC NEAR
mov ah, 9 ; DOS function number to print string
mov dx, OFFSET message1 ; the message
int 21h ; DOS interrupt
mov ah, 9 ; DOS function number to print string
mov dx, OFFSET message2 ; the message
int 21h ; DOS interrupt
again:
mov ah, 0 ; BIOS function wait for key press
int 16h ; BIOS interrupt
cmp ah, 1 ; Esc scan code
jz done ; do we stop ?
call phone_tone ; no call phone_tone
jmp again ; go see if we do it again
done:
mov ax, 4c00h ; no exit back to DOS
int 21h ; DOS interrupt
start ENDP
;----------------------------------
phone_tone PROC NEAR
cli ; disables any keyboard or other
; possible hardware interference
go_2:
mov si, 2 ; do the two six pulse groups, twice
mainx:
mov di, 2 ; do group of six pulses two times
mainy:
mov dx, 6 ; do six pulses of each tone
mainz:
mov bx, 2000 ; frequency of first tone
call in_out_2_port ; set timer chip and send (bx) to port
mov delay, 1 ; place first delay count in delay
call delayer ; wait a bit before next tone
mov bx, 1600 ; frequency of second tone
call in_out_2_port ; set timer chip and send (bx) to port
mov delay, 1 ; place first delay count in delay
call delayer ; wait a bit before next time
dec dx ; decrement pulse count
jnz mainz ; have we done six pulses ?
dec di ; yes go do second group of six pulses
jnz mainy ; have we done two groups ?
in al, 61h ; yes turn speaker off
and al, 11111100b ; this number turns speaker off
out 61h, al ; send it to port
mov delay, 20 ; place second delay count in delay
call delayer ; wait a while
dec si ; if si not 0 go do -
jnz mainx ; two more six pulse groups
sti ; time to enable interrupts
ret ; go see if user wants to go again
phone_tone ENDP
;----------------------------------
delayer PROC NEAR
push ax ; save these registers
push bx
push dx
mov ah, 0 ; want to read time
int 01ah ; get initial tick count
add dx, delay ; add our count to tick count
mov bx, dx ; place it in bx
delay_it:
int 01ah ; get reading again
cmp dl, bl ; compare reading to delay count
jne delay_it ; go back and repeat if not equal
pop dx
pop bx
pop ax ; restore used registers
ret
delayer ENDP
;--------------------------------------
in_out_2_port PROC NEAR
mov al, 10110110b ; channel 2
out 43h, al ; operation mode 3
mov ax, bx ; place freqrency in ax
out 42h, al ; send LSB first
mov al, ah ; place MSB in al
out 42h, al ; send it next
in al, 61h ; get 8255 port contents
or al, 00000011b ; this number turns speaker on
out 61h, al ; turn it on now
ret
in_out_2_port ENDP
;----------------------------------
code_seg ENDS
END begin